package com.redoor.app.stake.basicdata.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.redoor.app.stake.basicdata.model.BaseProp;
import com.redoor.app.stake.basicdata.model.controllerModel.BasePropCriteria;
import com.redoor.app.stake.basicdata.service.BasePropRedisService;
import com.redoor.app.stake.basicdata.service.BasePropService;
import com.redoornetwork.framework.core.response.ResponseResult;
import com.redoornetwork.framework.core.response.ResultGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
* Created by wangjunlei on 2018-03-10 17:05:59.
*/
@RestController
@RequestMapping("/base/props")
public class BasePropController {

    @Autowired
    private BasePropService basePropService;

    @Autowired
    private BasePropRedisService basePropRedisService;

    @GetMapping("/initPropToRedis")
    public ResponseResult initPropToRedis() {
        basePropService.initPropToRedis(true);
        return ResultGenerator.generatorSuccess();
    }

    @GetMapping("/getRegisterIndex")
    public ResponseResult getRegisterIndex() {
        return ResultGenerator.generatorSuccess(basePropService.getRegisterIndex());
    }

    @GetMapping
    public ResponseResult list() {
        List<BaseProp> list = basePropService.findAll();
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.generatorSuccess(pageInfo);
    }

}
